package com.hermes.comics.utils;

import android.text.TextUtils;
import android.widget.ImageView;

import com.hermes.comics.data.IssueTag;
import com.hermes.comics.data.Issue;

import com.squareup.picasso.Picasso;

public class ImageUtils {

  private ImageUtils() {}

  public static void setImage(Issue issue, ImageView imageView) {
    String imageUrl = IssueTag.IMG.value(issue);
    if (TextUtils.isEmpty(imageUrl)) {
      Picasso.with(imageView.getContext())
        .load(android.R.drawable.spinner_background)
        .error(android.R.drawable.spinner_background)
        .fit()
        .into(imageView);
    } else {
      Picasso.with(imageView.getContext())
        .load(imageUrl)
        .error(android.R.drawable.spinner_background)
        .placeholder(android.R.drawable.spinner_background)
        .fit()
        .into(imageView);
    }
  }
}
